
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="__CSS__/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__CSS__/my.css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="__JS__/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="__JS__/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            {block name='main'}
            <h3>管理员列表</h3>
            <table class="table table-hover table-bordered" style="text-align: center;">
                <tr>
                    <th style="text-align: center;">
                        id
                    </th>
                    <th style="text-align: center;">
                        姓名
                    </th>
                    <th style="text-align: center;">
                        拥有身份
                    </th>
                    <th style="text-align: center;">
                        操作
                    </th>
                </tr>
            {foreach $list as $v}
                <tr id="{$v['id']}">
                    <td>
                        {$v['id']}        
                    </td>
                    <td>
                        {$v['adminname']}
                    </td>
                    <td>
                        {foreach $arr[$v['id']] as $b}

                            {$b['role']}

                        {/foreach}
                    </td>
                    <td>
                        <a  href='{:url("admin/admininfo/edit?id=".$v["id"])}' class="btn btn-default  btn-success ">编辑</a>

                        <a  class="btn btn-default btn-danger del"  data_id="{$v['id']}">删除</a>
                    </td>
                </tr>   

            {/foreach}
            </table>
            <script>
                $(function(){
                    $('.del').click(function(){
                        var a = confirm('你确定删除吗!!!!!');
                        if (a) {

                            var id = $(this).attr('data_id');
                            $.ajax({
                                type:'post',
                                url:  '/admin/admininfo/delete',
                                data:{ 'id': id },
                                dataType:'json',
                                success: function(data){

                                    console.log(data);
                                    if (data>0) {
                                        $('#'+id).remove();
                                        alert('删除成功');
                                    }else{
                                        alert('删除失败');
                                    }  
                                },
                                error:function(){
                                    alert('ajax执行失败');
                                }

                            })
                        }
                    })
                })
            </script>

            {/block}
        </div>
    </div>
</div>
</body>
</html>